using System.Collections.Generic;
using InfiniTec.Data;

namespace InfiniTec.Expressions
{
    public class AndExpression: OperatorExpression
    {
        public AndExpression(params Expression[] expressions):
            this((IEnumerable<Expression>)expressions) { }

        public AndExpression(IEnumerable<Expression> expressions)
            : base(expressions)
        {           
        }

        public override bool Evaluate(PropertyCollection properties)
        {
            foreach (Expression expression in Expressions)
            {
                if (!expression.Evaluate(properties)) return false;
            }

            return true;
        }
    }
}
